package com.snail.jj.androiddemos.foundationwidgets;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.snail.jj.androiddemos.R;
import com.snail.jj.androiddemos.bases.BaseActivity;

/**
 * Created by snail on 2017/4/18.
 */

public class EditViewActivity extends BaseActivity {

    private final static String TAG = "EditViewActivity";

    private EditText editText;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_foundation_editview);
        initView();
    }

    public void initView() {
        setLeftViewVisiable(View.VISIBLE);
        editText = (EditText) findViewById(R.id.id_editView_edit1);
        editText.setText("dsaasdasdasd");
        editText.setHintTextColor(Color.BLUE);
        editText.setSingleLine(true);                           //单行
        editText.setInputType(InputType.TYPE_CLASS_NUMBER);     //键盘类型
        editText.setTextColor(Color.BLUE);
//        editText.setCursorVisible(false);                     //光标隐藏
        editText.setSelection(editText.length());
        editText.setHint("WuJianJian");                         //placeholer
        editText.setHintTextColor(Color.LTGRAY);

//        editText.setBackgroundColor(Color.RED);
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                String info = s + "-" + Integer.toString(start) + "-"
                        + String.valueOf(count) + "-" + after + "-" + editText.getText();

                Log.i(TAG,info);
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                String info = s + "-" + Integer.toString(start) + "-"
                        + String.valueOf(before) + "-" + count + "-" + editText.getText();

                Log.i(TAG,info);
            }

            @Override
            public void afterTextChanged(Editable s) {
                String info = s + "-" + editText.getText();
                Log.i(TAG,info);
            }
        });
    }



}
